/*
Kakine
ActionScript Framework
Copyright © 2011, PUNY, LLC.

This file is part of KAKINE.

KAKINE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

KAKINE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KAKINE.  If not, see <http://www.gnu.org/licenses/>.
*/ 
package com.puny.ball.utils
{
	import flash.geom.Point;
	
	public class Matrix2D extends Object {
		private var _matrix:Array = new Array();
		public function Matrix2D(matrix:Array)
		{
			_matrix = matrix;
		}
		
		public function multiplyByVector(vector:Point):Point {
			var x:Number = vector.x;
			var y:Number = vector.y;
			vector.x = _matrix[0][0]*x + _matrix[0][1]*y;
			vector.y = _matrix[1][0]*x + _matrix[1][1]*y;
			return vector;
		}
				
		public static function getRotation(r:Number):Matrix2D {
			return new Matrix2D([[Math.cos(r),-Math.sin(r)],
								 [Math.sin(r),Math.cos(r)]]);
		}
	}
}